<?php
/**
 * 诚信系统搜索类
 * @author hongruchen
 *
 */
class Search_Record extends Search_Base
{
	const _CONST_TB_MAIN_  = 'shop_record';
	const _CONST_TB_MAIN_AS_ = 'r';	
	public function __construct ()
	{
		parent::__construct (self::_CONST_TB_MAIN_,
				self::_CONST_TB_MAIN_AS_);
	}

	protected function prepare_search (& $query)
	{
		
	}

	protected function build_where ($query, $query_type = 'list')
	{
		foreach ((array) $query as $key=>$val){
			if($key == 'status'){
				$this->_query->where("{$key}",'=',$this->status($val));
			}else if($key == 'order_by'){
				$this->build_order_by($val);
			}else if($key == 'no_finish_status'){//不查诚信交易记录时用
				    $this->_query->where("order_status",'<>',"{$val}");
			}else{
				if (is_array($val) && !empty($val)){
					$this->_query->where("{$key}", 'in', $val);
				}else{
				    $this->_query->where("{$key}",'=',"{$val}");
				}
			}
		}
	}

	protected function status ($status)
	{
		$ret = '';
		$config = Kohana::config('shop.record_status');
		array_key_exists($status, $config) && $ret = $config[$status];
		return $ret;
	}

	protected function build_list ($result_list)
	{
		return $result_list;
	}
}